
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "tipo_direccion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoDireccion.findAll", query = "SELECT t FROM TipoDireccion t"),
    @NamedQuery(name = "TipoDireccion.findByCodTipDir", query = "SELECT t FROM TipoDireccion t WHERE t.codTipDir = :codTipDir"),
    @NamedQuery(name = "TipoDireccion.findByDesTipDir", query = "SELECT t FROM TipoDireccion t WHERE t.desTipDir = :desTipDir")})
public class TipoDireccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "cod_tip_dir")
    private String codTipDir;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "des_tip_dir")
    private String desTipDir;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoDireccion")
    private Collection<Direccion> direccionCollection;

    public TipoDireccion() {
    }

    public TipoDireccion(String codTipDir) {
        this.codTipDir = codTipDir;
    }

    public TipoDireccion(String codTipDir, String desTipDir) {
        this.codTipDir = codTipDir;
        this.desTipDir = desTipDir;
    }

    public String getCodTipDir() {
        return codTipDir;
    }

    public void setCodTipDir(String codTipDir) {
        this.codTipDir = codTipDir;
    }

    public String getDesTipDir() {
        return desTipDir;
    }

    public void setDesTipDir(String desTipDir) {
        this.desTipDir = desTipDir;
    }

    @XmlTransient
    public Collection<Direccion> getDireccionCollection() {
        return direccionCollection;
    }

    public void setDireccionCollection(Collection<Direccion> direccionCollection) {
        this.direccionCollection = direccionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTipDir != null ? codTipDir.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof TipoDireccion)) {
            return false;
        }
        TipoDireccion other = (TipoDireccion) object;
        if ((this.codTipDir == null && other.codTipDir != null) || (this.codTipDir != null && !this.codTipDir.equals(other.codTipDir))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.desTipDir;
    }
    
}
